const app = getApp();
var api = require('../../../config/api.js');
var wxcache = require('../../../utils/wxcache.js');
//import { Logistics } from 'logistics-model.js';
//var logistics = new Logistics(); //实例化 首页 对象
Page({
  data: {
    // 列表数据
    list: [],//物流详情列表 
    hasData: false
  },
  onLoad: function (options) {
    var that = this;
    var orderId = options.id;//order表主键id
    orderId = orderId.toString();
    //var type = options.type;//活动类型
    //var sid = options.sid;
    //app.globalData.sid = sid;
    // wx.showLoading({
    //   title: '查询物流信息中~',
    // })
    //模拟数据
    var list = {
      // com: "shunfeng",
      // comany: "顺丰速运",
      // condition: "D01",
      // data: [
      //   { time: "2019-01-13 17:13:21", ftime: "2019-01-13 17:13:21", context: "[快件已签收]已签收,感谢使用锦旗国旅,期待再次为您服务", display: 0 },
      //   { time: "2019-01-13 20:01:08", ftime: "2019-01-13 20:01:08", context: "[快件运送中]上海市闵行区顺丰快递已揽收，快件正在火速发送中", display: 1 },
      //   { time: "2019-01-13 20:39:47", ftime: "2019-01-13 20:39:47", context: "[快件已发货]锦旗国旅已为您发货（发件人：李可一，联系电话：13888888888）", display: 1 }
      // ],
      // image: "http://img.51miz.com/Element/00/83/77/33/843a123e_E837733_e92b9cac.png!/quality/90/unsharp/true/compress/true/format/png/fh/630",
      // ischeck: "1",
      // message: "ok",
      // nu: "467995890343",
      // state: "3",
      // state_cn: "已签收",
      // status: "200"
    }
    that.setData({
      list: list,
      hasData: true
     })
    var uid = wxcache.get("userInfo").id;
    var url = api.goodOrderDetail + "/" + orderId + "?p_u=" + uid;
    var data = {};
    wx.request({
      url: url,
      method: "GET",
      data: data,
      success: function (res) {
        if (res.data.message == "ok") {
          var orderDetailList = res.data.responseBody;
          // orderDetailList.campaignName,
          // orderDetailList.cusOrderId,
          // orderDetailList.status,
          // orderDetailList.primaryImageUrl[0],
          var res_list = {
            com: "JinQi",
            comany: "锦旗国旅",
            condition: "D01",
            data: [
              { time: orderDetailList.orderAt, ftime: orderDetailList.orderAt, context: "[快件运送中]上海市快递已揽收，快件正在火速发送中", display: 0 },
              { time: orderDetailList.orderAt, ftime: orderDetailList.orderAt, context: "[快件已发货]锦旗国旅已为您发货", display: 1 }
            ],
            image: orderDetailList.primaryImageUrl[0],
            ischeck: "1",
            message: "ok",
            nu: orderDetailList.cusOrderId,
            state: "3",
            state_cn: "运送中"
          };
          that.setData({
            list: res_list
          })
        }
      }
    }); 



    //这里执行根据物流单号查询物流信息,封装调用方法可以参考前面的几篇博文
    // logistics.getLogistics(orderId, sid, type, result => {
    //   if (result.code == '001') {
    //     that.setData({
    //       list: result.data,
    //       hasData: true
    //     })
    //   } else {
    //     that.setData({
    //       hasData: false
    //     })
    //   }
    //   wx.hideLoading();
    // })
  }
})
